package cn.kgc.Thread.work.work06;

public class OddEvenThread implements Runnable {
    @Override
    public void run() {
        for (int i = 1; i <100 ; i++) {
            String threadName=Thread.currentThread().getName();
            if (i%2==0 &&"even-thread".equals(threadName)){
                System.out.println( threadName + "偶数为：" + i);
            }else if (i%2!=0 && "odd-thread".equals(threadName)){
                System.out.println( threadName + "奇数为：" + i);
            }
        }
    }

    public static void main(String[] args) {
        OddEvenThread target=new OddEvenThread();
        Thread odd=new Thread(target,"odd-thread");
        Thread even=new Thread(target,"even-thread");
        odd.start();
        even.start();
    }
}
